//
//  InvisibleListVC.m
//  SelfDriving
//
//  Created by apple on 16/1/19.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "InvisibleListVC.h"
#import "BlackCell.h"
#import "BusinessService+WD.h"
@interface InvisibleListVC ()<BaseTableDetelage>
@property (weak, nonatomic) IBOutlet BaseTable *table;

@end

@implementation InvisibleListVC{
    UILabel *notlabel;
    NSMutableArray *data;
}

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [self initData:1]; //xhw2018-1-25加
}



- (void)viewDidLoad {
    [super viewDidLoad];
    data = [[NSMutableArray alloc]init];
    _table.bdelegate = self;
    
    
}

-(void)initData:(int)index{
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:[NSNumber numberWithInt:index] forKey:@"page"];
    [[BusinessService shareInstance]yinshen_list:dic success:^(id result) {
        data = [_table result:result olddata:data index:index];
        if (notlabel) {
            [notlabel removeFromSuperview];
        }
        notlabel = (UILabel *)[_table notData];
        if (data.count == 0) {
            [self.view addSubview:notlabel];
        }
        [_table reloadData];
    } failure:^(id result) {
        [SVProgressHUD showErrorWithStatus:result];
    }];
    
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return data.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BlackCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BlackCell"];
    cell.imghead.layer.cornerRadius = cell.imghead.frame.size.width/2;
    cell.btnClater.layer.cornerRadius = 4;
    cell.btnClater.layer.borderColor = UIColorFromRGB(0xE6E8E8).CGColor;
    cell.btnClater.layer.borderWidth = 0.5;
    cell.btnClater.tag = indexPath.row;
    LoginResponseModel *user = [data objectAtIndex:indexPath.row];
    [cell.imghead sd_setImageWithURL:[NSURL URLWithString:user.headsmall] placeholderImage:[UIImage imageNamed:@"mrtx"]];
    cell.imghead.clipsToBounds = YES;
    cell.labelname.text = user.nickname;
    cell.btnClater.backgroundColor = UIColorFromRGB(0xF0F1F2);
    [cell.btnClater setBackgroundImage:[ImageService imageWithColor:UIColorFromRGB(0xE54848) img:[UIImage imageNamed:@"zhbg"]] forState:UIControlStateHighlighted];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return  cell;
}
#pragma  mark 取消隐身
- (IBAction)quxiaoAction:(UIButton *)sender {
    LoginResponseModel *user = [data objectAtIndex:sender.tag];
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:user.uid forKey:@"fid"];
    [dic setObject:@"0" forKey:@"type"];
    [[BusinessService shareInstance]yinshen:dic success:^(id result) {
        [SVProgressHUD showSuccessWithStatus:@"取消成功"];
        [_table Refresh];
    }failure:^(id result) {
        [SVProgressHUD showErrorWithStatus:result];
    }];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}

- (IBAction)backActino:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
